using System.Reflection.Emit;
using NHibernate;
using NHibernate.Cfg.MappingSchema;
using NHibernate.Mapping.ByCode;

namespace Crux.Core.NHibernate.Test;
/// <summary>
/// TestDbContext
/// </summary>
public class TestDbContext : NHibernateContext
{
    /// <summary>
    ///
    /// </summary>
    public TestDbContext(ISession session) : base(session)
    {
    }

    public static HbmMapping BuildMapping()
    {
        HashSet<Type> mappingClassList = new HashSet<Type>();
        #region adminUsers

        mappingClassList.Add(typeof(TestModelMapping));
        #endregion

        var mapper = new ModelMapper();
        mapper.AddMappings(mappingClassList);

        var mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();
        return mapping;
    }
}